package com.eliza.demo.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import com.eliza.demo.R
import com.eliza.library.tools.InfoTools

class LoginActivity : AppCompatActivity() {
    private val context = this
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)
        val tv = findViewById<TextView>(R.id.login_tv_show)

        val etv = findViewById<EditText>(R.id.login_etv)
//                override fun onTextChanged(text: CharSequence?, start: Int, before: Int, count: Int)
        etv.addTextChangedListener(object : TextWatcher {
            override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
            }

            override fun onTextChanged(text: CharSequence?, p1: Int, p2: Int, p3: Int) {
                text?.let {
                    InfoTools.LogTools("TAg", text)
                    if (text.toString() == "abc123") {
                        tv.text = "欢迎进入快乐大本营"
                    } else if (text.toString().isEmpty()) {
                        tv.text = ""
                    } else {
                        tv.text = "非法用户"
                    }
                }
            }

            override fun afterTextChanged(p0: Editable?) {
            }
        })


    }
}